package com.wujin.provider.dubbo.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wujin.provider.dao.UserDao;
import com.wujin.provider.dubbo.provider.DemoService;
import com.wujin.provider.model.User;
import com.wujin.provider.model.UserBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author Wu Jin
 * @create 2018-04-03 下午 6:32
 * https://github.com/apache/incubator-dubbo-spring-boot-project
 */
@Service(interfaceClass = DemoService.class)
@Component
public class DefaultDemoService implements DemoService {

    @Autowired
    private UserDao userDao;

    @Override
    public String sayHello(String name) {
        return "Hello, " + name + " (from Spring Boot)";
    }

    @Override
    public List<User> list() {
        return userDao.findAll();
    }

    @Override
    public PageInfo<UserBean> list2(int num, int size) {
        Page<UserBean> userBeans = PageHelper.startPage(num, size, "id desc");
        userDao.findAll();
        return userBeans.toPageInfo();
    }

}
